package com.test;

import java.util.HashSet;
import java.util.Properties;
import java.util.Set;

public class test2 {

    public static void main(String[] args) {
        int[] r = new int[]{0,0,0,6,5,4,3,2,1,7,7,5,4,9,10,-13,18,19,-21,-13};
        getNumbers(r);


    }

    //获得重复的元素
    public static void getNumbers(int[] data){
        if(data == null || data.length == 0){
            return;
        }
        int[] list = data;
        QuickSort(list,0,list.length-1);
        Set<Integer> set = new HashSet<Integer>();
        for(int i = 1;i<list.length;i++){
            if(list[i] == list[i-1]){
                set.add(list[i]);
            }
        }

        set.forEach(System.out::println);
    }

    public static int Partition(int data[],int start,int end){
        int temp = data[start];
        while(start < end){
            while(start < end && data[end] >= temp){
                end--;
            }
            data[start] = data[end];
            while(start < end && data[start] <= temp){
                start++;
            }
            data[end] = data[start];
        }
        data[start] = temp;
        return start;
    }

    public static void QuickSort(int[] data,int start,int end){
        if(start < end){
            int temp = Partition(data,start,end);
            QuickSort(data,start,temp-1);
            QuickSort(data,temp+1,end);
        }
    }
}
